package org.keyroy.map_editor.core.map_tile;

import java.awt.Point;

import org.keyroy.map_editor.core.Map;
import org.keyroy.map_editor.core.MapOverLay;

public class TileOverLay extends MapOverLay {
	private Tile[][] tiles;

	public TileOverLay(Map map) {
		super(map);
	}

	@Override
	protected Object getObjectList() {
		return tiles;
	}

	@Override
	protected void init(Map map) {
		tiles = new Tile[map.getColumns()][map.getRows()];
	}

	public void set(Point point, Tile[][] tiles) {
		for (int x = 0; x < tiles.length; x++) {
			int tx = point.x - (tiles.length / 2) + x;
			for (int y = 0; y < tiles[x].length; y++) {
				int ty = point.y - (tiles[x].length / 2) + y;
				this.tiles[tx][ty] = tiles[x][y];
			}
		}
		map.callMapChange();
	}

}
